package vrp;

import java.io.IOException;
import javax.jdo.PersistenceManager;
import javax.servlet.http.*;

import vrp.PMF;
import vrp.WHProvider;


public class WHProviderAddServlet extends HttpServlet {

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws IOException {

        PersistenceManager pm = PMF.get().getPersistenceManager();

        String name = req.getParameter("name");
        String address = req.getParameter("address");
        String postalCode = req.getParameter("postalCode");
        String contactNo = req.getParameter("contactNo");

        try {
        	WHProvider whProvider = new WHProvider(name, address, postalCode, contactNo);
            pm.makePersistent(whProvider);
        } finally {
            pm.close();
        }
        resp.sendRedirect("/whProviders.jsp");
    }
}
